package bishihuizong;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by JiaJia on 2019/9/15 0015.
 */
public class ZHaoHangxinyongka03 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
       // while (scanner.hasNext()){
            //String input=scanner.nextLine();
            String input="???5";
            char[] chars=input.toCharArray();
            ArrayList<String> list=new ArrayList<>();
            generateNumber(chars,0,list);
            System.out.println(countSize(list));
       // }
       // scanner.close();
    }
    private static void generateNumber(char[] chars,int digit,ArrayList<String> list){
        if (digit==chars.length-1){
            list.add(new String(chars));
            return;
        }
        for (int i = 0; i <10; i++) {
            if (chars[digit]=='?'){
                chars[digit]=(char)(i+'0');
                generateNumber(chars,digit+1,list);
            }
            //generateNumber(chars,digit+1,list);
        }
    }
    private static long countSize(ArrayList<String> list){
        long size=0;
        ArrayList<String> res=new ArrayList<>();
        for (String str:list) {
            long a=Long.valueOf(str);
            if (a%13==5){
                res.add(str);
            }
        }
        size=res.size();
        return size%(1000000000+7);
    }
}